<template>
    <simple-table v-bind="$attrs" v-on="$listeners" ref="myTable">
        <template  v-for="(item,index) in config">
            <template v-if="item.click==undefined">
                <my-table-column :prop="item.prop" :label="item.label" :key="index"
                                 :formatter="item.formatter" :width="item.width" :min-width="item.minWidth" show-overflow-tooltip>
                </my-table-column>
            </template>
            <template v-else>
                <el-table-column :prop="item.prop" :label="item.label" :key="index" :formatter="item.formatter" :width="item.width" :min-width="item.minWidth" show-overflow-tooltip>
                    <template slot-scope="{row}">
                        <my-link @to="doSomething(item.click,row)">{{row.title}}</my-link>
                    </template>
                </el-table-column>
            </template>
        </template>
        <slot name="otherClolumn"></slot>
        <el-table-column align="left" fixed="right" label="操作" :min-width="operMinWidth" v-if="showOperation">
            <template slot-scope="{row}">
                <slot :row="row"></slot>
            </template>
        </el-table-column>
    </simple-table>
</template>
<script>
    import MyTableColumn from "../TableColumn/MyTableColumn";
    import MyLink from "../MyLink/index";
    export default {
        name: "DynamicTable",
        components: {MyLink, MyTableColumn},
        props: {
            config:{
                type:Array,
                default:function () {
                    return []
                }
            },
            showOperation:{
                type:Boolean,
                default:true
            },
            operMinWidth:{
                type:[String,Number],
                default:120
            }
        },
        data() {
            return {};
        },
        created() {
        },
        watch: {},
        methods: {
            doSomething(func,row){
                this.$emit(func,row)
            },
            searchList(queryData) {
                this.$refs["myTable"].searchList(queryData);
            },
        }
    };
</script>
